package com.gonsin.gview.model.dynamic.data;

import com.gonsin.gview.annotations.impl.EmptyDataPicker;
import com.gonsin.gview.annotations.interfaces.IDataPicker;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class DynamicData {

    /**
     * 直接输入sql语句查询数据（如果查询到多个，则会返回第一个）
     */
    private String fromSql = "";
    public static DynamicData fromSql(String sql){
        DynamicData data = new DynamicData();
        data.fromSql = sql;
        return data;
    }

    /**
     * 通过dataPicker写java语句查询数据（此方法最为灵活）
     */
    private IDataPicker fromDataPicker;
    public static DynamicData fromDataPicker(IDataPicker fromDataPicker){
        DynamicData data = new DynamicData();
        data.fromDataPicker = fromDataPicker;
        return data;
    }


    /**
     * 通过dataPicker写java语句查询数据（此方法最为灵活）
     */
    private String fromDataPickerClassName = "";
    public static DynamicData fromDataPickerClassName(String fromDataPickerClassName){
        DynamicData data = new DynamicData();
        data.fromDataPickerClassName = fromDataPickerClassName;
        return data;
    }


    /**
     * 通过静态json返回，适合静态数据
     */
    private String fromJson = "";
    public static DynamicData fromJson(String fromJson){
        DynamicData data = new DynamicData();
        data.fromJson = fromJson;
        return data;
    }

    /**
     * 通过数据源获取数据
     */
    private String fromDataSource = "";
    public static DynamicData fromDataSource(String fromDataSource){
        DynamicData data = new DynamicData();
        data.fromDataSource = fromDataSource;
        return data;
    }

    private DynamicData(){}
    
}
